﻿using System;
using System.Windows.Forms;
using Kyoh.App.Crawler.Plugin;
using Kyoh.Lib.Plugin;
using System.Runtime.InteropServices;

namespace Kyoh.App.Crawler.Contents
{
    [Guid("ECAEDC8B-8DAD-4C0C-AA02-4FCA935E1776")]
    public class DefaultPicker : IPicker
    {
        public IAnchor GetAnchor(IRedirect redirect)
        {
            using (var form = new DefaultPickerForm())
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    var uri = redirect.Parse(form.AnchorUri);
                    if (!string.IsNullOrEmpty(uri))
                        return new Anchor { Title = form.AnchorTitle, Uri = uri, Priority = form.AnchorPriority, };
                }
            }
            return null;
        }

        public string Author { get { return "kyoh"; } }
        public string Description { get { return string.Empty; } }
        public Uri Uri { get { return new Uri("http://kyoh.net/"); } }

        public object Preferences
        {
            get { return null; }
            set { }
        }
        public string Name { get { return "DefaultPicker"; } }

        public void Dispose() { Dispose(true); }
        ~DefaultPicker() { Dispose(false); }
        protected void Dispose(bool disposing) { }
    }
}
